{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 4a. Calculate fugacity coefficients\n", "\n", "This allows you to calculate the fugacity coefficient for all vapor species in the CHOSX system at a given *P* and *T*.\n", "\n", "It can be run for multiple sets of conditions defined in the input data frame or loaded from a csv file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Python set-up\n", "You need to install VolFe once on your machine, if you haven't yet. Then we need to import a few Python packages (including VolFe). " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Install VolFe on your machine. Don't remove the # from this line!\n", "# pip install VolFe # Remove the first # in this line if you have not installed VolFe on your machine before.\n", "\n", "# import python packages\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import VolFe as vf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Conditions from dataframe\n", "\n", "### Define the inputs\n", "\n", "This first example is for a single set of conditions defined in a dataframe." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Define conditions T as a dictionary.\n", "my_analysis = {'Sample':'test',\n", " 'T_C': 1200., # Temperature in 'C\n", " 'P_bar':1000.} # Pressure in bar\n", "\n", "# Turn the dictionary into a pandas dataframe, setting the index to 0.\n", "my_analysis = pd.DataFrame(my_analysis, index=[0])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We'll use the default options" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " option\n", "type \n", "COH_species yes_H2_CO_CH4_melt\n", "H2S_m True\n", "species X Ar\n", "Hspeciation none\n", "fO2 Kress91A\n", "... ...\n", "error 0.1\n", "print status False\n", "output csv True\n", "setup False\n", "high precision False\n", "\n", "[78 rows x 1 columns]\n" ] } ], "source": [ "# print default options in VolFe\n", "print(vf.default_models)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Run the calculation\n", "\n", "And this runs the calculation" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | Sample | \n", "P_bar | \n", "T_C | \n", "yO2 | \n", "yH2 | \n", "yH2O | \n", "yS2 | \n", "ySO2 | \n", "yH2S | \n", "yCO2 | \n", "... | \n", "y_H2S opt | \n", "y_H2 opt | \n", "y_O2 opt | \n", "y_S2 opt | \n", "y_CO opt | \n", "y_CH4 opt | \n", "y_H2O opt | \n", "y_OCS opt | \n", "y_X opt | \n", "Date | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "test | \n", "1000.0 | \n", "1200.0 | \n", "1.209858 | \n", "1.126166 | \n", "1.004254 | \n", "1.191327 | \n", "1.206456 | \n", "1.489942 | \n", "1.265765 | \n", "... | \n", "Shi92_Hughes24 | \n", "Shaw64 | \n", "Shi92 | \n", "Shi92 | \n", "Shi92 | \n", "Shi92 | \n", "Holland91 | \n", "Shi92 | \n", "ideal | \n", "2025-02-02 10:12:53.052359 | \n", "
1 rows × 26 columns
\n", "